package com.foreknow.demo10;

/**
 *方法的重载OverLoad
 * 一个类中可以有多个同名的方法,但参数不同,与返回值类型无关
 */
public class OverLoad {
    public void add(int a,int b){
        System.out.println(a+b);

    }
    public int add(int a,int b,int c){
        return a+b+c;
    }
    public String add(int a,int b,String c){
        return a+b+c;
    }

    public static void main(String[] args) {
        OverLoad overLoad = new OverLoad();
        overLoad.add(1,1);
        int i= overLoad.add(1,12,2);
        System.out.println(i);
        String m = overLoad.add(1,23,"21");
        System.out.println(m);
    }
}
